package com.ylz.sjzx.sio.common.core.core;

import com.ylz.sjzx.sio.common.core.core.container.common.annotation.AdapterDesc;

import java.util.HashMap;

/**
 * Description:
 *
 * @date:2021/9/15
 * @author:wiqi
 */
public class SioBase {

    /**
     * String 为key  IMRequestHandler 为业务处理器
     */
    private static final HashMap<String, IAdapter> innerAdapterMap = new HashMap<>();

    /**
     * 参数
     */
    private static ThreadLocal<Object> tparam = new ThreadLocal<>();

    /**
     * 异常
     */
    private static ThreadLocal<Throwable> tException = new ThreadLocal<>();

    /**
     * adapter参数
     */
    private static ThreadLocal<AdapterDesc> tIAdapterDesc = new ThreadLocal<>();


    public static AdapterDesc getIAdapterDesc() {
        return tIAdapterDesc.get();
    }

    public static void setIAdapterDesc(AdapterDesc adapterDesc) {
        tIAdapterDesc.set(adapterDesc);
    }

    public static HashMap<String, IAdapter> getInnerAdapterMap() {
        return innerAdapterMap;
    }


    public static void clean() {
        tException.remove();
        tparam.remove();
        tIAdapterDesc.remove();
    }


    public static Object getParam() {
        return tparam.get();
    }

    public static void setParam(Object param) {
        tparam.set(param);
    }

    public static Throwable getException() {
        return tException.get();
    }

    public static void setException(Throwable param) {
        tException.set(param);
    }
}
